package Parkour;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;


public class MainFrame extends JFrame implements MouseListener {

    JLabel start,help,exit;

    JPanel MainPanel;

    public MainFrame() {

        start = new JLabel(new ImageIcon("images/parkour/hh1.png"));
        start.setBounds(350,320,150,40);
        start.setEnabled(false);
        start.addMouseListener(this);
        this.add(start);

        help = new JLabel(new ImageIcon("images/parkour/hh2.png"));
        help.setBounds(350,420,150,40);
        help.setEnabled(false);
        help.addMouseListener(this);
        this.add(help);

        exit = new JLabel(new ImageIcon("images/parkour/hh3.png"));
        exit.setBounds(350, 520, 150, 40);
        exit.setEnabled(false);
        exit.addMouseListener(this);
        this.add(exit);

        MainPanel panel = new MainPanel();
        this.add(panel);
        this.setSize(1200,730);
        this.setLocationRelativeTo(null);
        this.setUndecorated(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setIconImage(new ImageIcon("images/parkour/115.png").getImage());
        this.setVisible(true);
    }

    public static void main(String[] args) {
        new MainFrame();
    }


    class MainPanel extends JPanel{
        Image background;
        public MainPanel() {
            try {
                background = ImageIO.read(new File("images/parkour/main.png"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        @Override
        public void paint(Graphics g) {
            super.paint(g);
            g.drawImage(background, 0, 0,1200,730, null);
        }
    }

    @Override
    public void mouseClicked(MouseEvent e) {

        if(e.getSource().equals(start)){
            new WindowFrame().Start();
        }else if(e.getSource().equals(exit)){
            dispose();
        }else if(e.getSource().equals(help)){
            JOptionPane.showMessageDialog(null, "有疑问请联系开发者：Huey");
        }

    }

    @Override
    public void mousePressed(MouseEvent e) {

    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }


    @Override
    public void mouseEntered(MouseEvent e) {
        if(e.getSource().equals(start)){
            start.setEnabled(true);
        }else if(e.getSource().equals(help)){
            help.setEnabled(true);
        }else if(e.getSource().equals(exit)){
            exit.setEnabled(true);
        }
    }

    @Override
    public void mouseExited(MouseEvent e) {
        if(e.getSource().equals(start)){
            start.setEnabled(false);
        }else if(e.getSource().equals(help)){
            help.setEnabled(false);
        }else if(e.getSource().equals(exit)){
            exit.setEnabled(false);
        }
    }

}